home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1998 January / Cd Pc Users extra 16 enero 1999.iso / prog / inst / renamer / form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-11-27  |  4.5 KB  |  160 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "File Renamer"
  4.    ClientHeight    =   5685
  5.    ClientLeft      =   720
  6.    ClientTop       =   705
  7.    ClientWidth     =   6585
  8.    Height          =   6090
  9.    Icon            =   "Form1.frx":0000
  10.    Left            =   660
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5685
  13.    ScaleWidth      =   6585
  14.    Top             =   360
  15.    Width           =   6705
  16.    Begin VB.FileListBox File1 
  17.       Height          =   4350
  18.       Left            =   2760
  19.       TabIndex        =   9
  20.       Top             =   120
  21.       Width           =   3735
  22.    End
  23.    Begin VB.DriveListBox Drive1 
  24.       Height          =   315
  25.       Left            =   120
  26.       TabIndex        =   8
  27.       Top             =   120
  28.       Width           =   2535
  29.    End
  30.    Begin VB.DirListBox Dir1 
  31.       Height          =   4590
  32.       Left            =   120
  33.       TabIndex        =   7
  34.       Top             =   480
  35.       Width           =   2535
  36.    End
  37.    Begin VB.TextBox txtNumberFrom 
  38.       Height          =   285
  39.       Left            =   5280
  40.       TabIndex        =   2
  41.       Text            =   "1"
  42.       Top             =   5040
  43.       Width           =   1215
  44.    End
  45.    Begin VB.CommandButton cmdGo 
  46.       Caption         =   "Go"
  47.       Enabled         =   0   'False
  48.       Height          =   615
  49.       Left            =   2760
  50.       TabIndex        =   3
  51.       Top             =   4680
  52.       Width           =   855
  53.    End
  54.    Begin VB.TextBox txtDirectory 
  55.       Enabled         =   0   'False
  56.       Height          =   285
  57.       Left            =   120
  58.       TabIndex        =   0
  59.       Text            =   "C:\"
  60.       Top             =   5400
  61.       Width           =   6375
  62.    End
  63.    Begin VB.TextBox txtPrefix 
  64.       Height          =   285
  65.       Left            =   5280
  66.       TabIndex        =   1
  67.       Text            =   "Pic_"
  68.       Top             =   4680
  69.       Width           =   1215
  70.    End
  71.    Begin VB.Label Label1 
  72.       Alignment       =   1  'Right Justify
  73.       Caption         =   "Number From"
  74.       Height          =   255
  75.       Index           =   2
  76.       Left            =   3720
  77.       TabIndex        =   6
  78.       Top             =   5040
  79.       Width           =   1455
  80.    End
  81.    Begin VB.Label Label1 
  82.       Alignment       =   1  'Right Justify
  83.       Caption         =   "File Name Prefix"
  84.       Height          =   255
  85.       Index           =   1
  86.       Left            =   3720
  87.       TabIndex        =   5
  88.       Top             =   4680
  89.       Width           =   1470
  90.    End
  91.    Begin VB.Label Label1 
  92.       Caption         =   "Full Path"
  93.       Height          =   255
  94.       Index           =   0
  95.       Left            =   120
  96.       TabIndex        =   4
  97.       Top             =   5160
  98.       Width           =   750
  99.    End
  100. Attribute VB_Name = "Form1"
  101. Attribute VB_Creatable = False
  102. Attribute VB_Exposed = False
  103. Option Explicit
  104. Private Sub cmdGo_Click()
  105. Dim directory As String
  106. Dim filename As String
  107. Dim filenames As New Collection
  108. Dim prefix As String
  109. Dim i As Integer
  110. Dim Index As Integer
  111. Dim pos As Integer
  112. Dim extension As String
  113. Dim new_name As String
  114.     MousePointer = vbHourglass
  115.     directory = Trim$(txtDirectory.Text)
  116.     If Right$(directory, 1) <> "\" Then _
  117.         directory = directory & "\"
  118.     ' Get the file names.
  119.     filename = Dir(directory & "*.*")
  120.     Do While filename <> ""
  121.         filenames.Add filename
  122.         filename = Dir
  123.     Loop
  124.     ' Rename the files.
  125.     Index = CInt(txtNumberFrom.Text)
  126.     prefix = Trim$(txtPrefix.Text)
  127.     For i = 1 To filenames.Count
  128.         filename = filenames(i)
  129.         pos = InStr(filename, ".")
  130.         If pos > 0 Then
  131.             extension = Right$(filename, Len(filename) - pos + 1)
  132.         Else
  133.             extension = ""
  134.         End If
  135.         Name directory & filename As _
  136.              directory & prefix & _
  137.                 Format$(Index) & extension
  138.         Index = Index + 1
  139.     Next i
  140.     MousePointer = vbDefault
  141.     MsgBox "Moved" & Str$(filenames.Count) & " files."
  142.     File1.Refresh
  143. End Sub
  144. Private Sub Dir1_Change()
  145. File1.Path = Dir1
  146. txtDirectory = Dir1
  147. cmdGo.Enabled = True
  148. If txtDirectory = "c:\" Or txtDirectory = "c:\WINDOWS" Then
  149.     cmdGo.Enabled = False
  150. End If
  151. End Sub
  152. Private Sub Drive1_Change()
  153. Dir1.Path = Drive1
  154. txtDirectory = Dir1
  155. End Sub
  156. Private Sub Form_Load()
  157. Drive1 = "C:\"
  158. cmdGo.Enabled = False
  159. End Sub
  160.